package me.imvc.generate.template;

import java.util.*;

public class ViewIndexTemplate
{
  protected static String nl;
  public static synchronized ViewIndexTemplate create(String lineSeparator)
  {
    nl = lineSeparator;
    ViewIndexTemplate result = new ViewIndexTemplate();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "<%@ page language=\"java\" contentType=\"text/html; charset=UTF-8\" pageEncoding=\"UTF-8\"%>" + NL + "<%@taglib prefix=\"c\" uri=\"http://java.sun.com/jsp/jstl/core\" %>" + NL + "<%@ taglib uri=\"http://java.sun.com/jsp/jstl/functions\" prefix=\"fn\"%>" + NL + "<form id=\"pagerForm\" pageNum=\"";
  protected final String TEXT_2 = ".pageNum\" numPerPage=\"";
  protected final String TEXT_3 = ".numPerPage\" " + NL + "orderField=\"";
  protected final String TEXT_4 = ".orderField\" orderDirection=\"";
  protected final String TEXT_5 = ".orderDirection\" method=\"GET\" action=\"#rel#\">" + NL + "    <input type=\"hidden\" name=\"";
  protected final String TEXT_6 = ".pageNum\" value=\"${";
  protected final String TEXT_7 = ".pageNum}\" />" + NL + "\t<input type=\"hidden\" name=\"";
  protected final String TEXT_8 = ".numPerPage\" value=\"${";
  protected final String TEXT_9 = ".numPerPage}\" />" + NL + "\t<input type=\"hidden\" name=\"";
  protected final String TEXT_10 = ".orderField\" value=\"${";
  protected final String TEXT_11 = ".orderField}\" />" + NL + "\t<input type=\"hidden\" name=\"";
  protected final String TEXT_12 = ".orderDirection\" value=\"${";
  protected final String TEXT_13 = ".orderDirection}\" />" + NL + "</form>" + NL + "<div class=\"pageHeader\">" + NL + "\t<form class=\"advancedSearchForm\" rel=\"pagerForm\"  onsubmit=\"return navTabSearch(this);\" action=\"${webUrl}/";
  protected final String TEXT_14 = "\" method=\"POST\">" + NL + "\t<div class=\"searchBar\">" + NL + "<%-- ===================修改搜索条件===================== --%>" + NL + "\t\t<ul class=\"searchContent\">" + NL + "\t\t\t<li>" + NL + "\t\t\t\t<label>ID：</label>" + NL + "\t\t\t\t<input type=\"text\" name=\"";
  protected final String TEXT_15 = ".searchParams.id_eq\" value=\"${";
  protected final String TEXT_16 = ".searchParams.id_eq}\"/>" + NL + "\t\t\t</li>" + NL + "\t\t</ul>" + NL + "<%-- ===================修改搜索条件===================== --%>" + NL + "\t\t<div class=\"subBar\">" + NL + "\t\t\t<ul>" + NL + "\t\t\t\t<li><div class=\"buttonActive\"><div class=\"buttonContent\"><button type=\"submit\">检索</button></div></div></li>" + NL + "\t\t\t\t<li><a class=\"button fullTextSearch\"><span>模糊搜索</span></a></li>" + NL + "\t\t\t</ul>" + NL + "\t\t</div>" + NL + "\t</div>" + NL + "\t</form>" + NL + "\t" + NL + "<form class=\"fullTextSearchForm\" style=\"display: none;\" rel=\"pagerForm_hidden\" onsubmit=\"return navTabSearch(this);\" action=\"${webUrl}/";
  protected final String TEXT_17 = "/0/search\" method=\"POST\">" + NL + "\t<div class=\"searchBar\" style=\"text-align: center;\">" + NL + "\t<ul class=\"searchContent\">" + NL + "\t搜索内容：<input type=\"text\" size=\"30\" name=\"";
  protected final String TEXT_18 = ".search\" value=\"${";
  protected final String TEXT_19 = ".search}\"/>" + NL + "\t<%-- ===================修改搜索字段===================== --%>" + NL + "\t<input type=\"hidden\"  name=\"";
  protected final String TEXT_20 = ".searchField\" value=\"id\"/>" + NL + "\t<%-- ===================修改搜索字段===================== --%>" + NL + "\t</ul>" + NL + "\t\t<div class=\"subBar\">" + NL + "\t\t\t<ul>" + NL + "\t\t\t\t<li><div class=\"buttonActive\"><div class=\"buttonContent\"><button type=\"submit\">搜索</button></div></div></li>" + NL + "\t\t\t\t<li><a class=\"button advancedSearch\"><span>高级检索</span></a></li>" + NL + "\t\t\t</ul>" + NL + "\t\t</div>" + NL + "\t</div>" + NL + "\t</form>\t" + NL + "</div>" + NL + "" + NL + "<div class=\"pageContent\">" + NL + "\t<div class=\"panelBar\">" + NL + "\t\t<ul class=\"toolBar\">" + NL + "\t\t\t<li><a class=\"add\" href=\"${webUrl}/";
  protected final String TEXT_21 = "/new\" target=\"dialog\" width=\"800\" height=\"480\" rel=\"";
  protected final String TEXT_22 = "_new\"><span>增加用户</span></a></li>" + NL + "\t\t\t<li><a title=\"确实要删除这些记录吗?\" target=\"selectedTodo\" rel=\"";
  protected final String TEXT_23 = ".ids\" href=\"${webUrl}/";
  protected final String TEXT_24 = "/0?_method=delete\" class=\"delete\"><span>批量删除</span></a></li>" + NL + "\t\t\t<li><a class=\"edit\" href=\"${webUrl}/";
  protected final String TEXT_25 = "/{data_id}/edit\" rel=\"";
  protected final String TEXT_26 = "_edit\"  target=\"dialog\" width=\"800\" height=\"480\" warn=\"请选择一个用户\"><span>修改</span></a></li>" + NL + "\t\t\t<li class=\"line\">line</li>" + NL + "\t\t\t<li><a class=\"icon\" href=\"${webUrl}/";
  protected final String TEXT_27 = ".xls\" target=\"dwzExport\" targetType=\"navTab\" title=\"是要导出这些记录吗?\"><span>导出EXCEL</span></a></li>" + NL + "\t\t</ul>" + NL + "\t</div>" + NL + "<%-- ===================修改table显示内容===================== --%>" + NL + "\t<table class=\"table\"  width=\"1200\" layoutH=\"138\">" + NL + "\t\t<thead>" + NL + "\t\t\t<tr>" + NL + "\t\t\t\t<th width=\"22\"><input type=\"checkbox\" group=\"";
  protected final String TEXT_28 = ".ids\" class=\"checkboxCtrl\"></th>" + NL + "\t\t\t\t";
  protected final String TEXT_29 = NL + "\t\t\t\t<th width=\"100\" orderField=\"";
  protected final String TEXT_30 = "\" class=\"asc\">";
  protected final String TEXT_31 = "</th>\t\t\t\t" + NL + "\t\t\t\t";
  protected final String TEXT_32 = NL + "\t\t\t\t<th width=\"90\">操作</th>" + NL + "\t\t\t</tr>" + NL + "\t\t</thead>" + NL + "\t\t<tbody>" + NL + "\t\t\t<c:forEach var=\"data\" items=\"${";
  protected final String TEXT_33 = ".dataList}\" varStatus=\"status\">" + NL + "\t\t\t<tr target=\"data_id\" rel=\"${data.id}\">" + NL + "\t\t\t\t<td><input name=\"";
  protected final String TEXT_34 = ".ids\" value=\"${data.id}\" type=\"checkbox\"></td>" + NL + "\t\t\t\t";
  protected final String TEXT_35 = NL + "\t\t\t\t<td>${data.";
  protected final String TEXT_36 = "}</td>" + NL + "\t\t\t\t";
  protected final String TEXT_37 = NL + "\t\t\t\t<td>" + NL + "\t\t\t\t\t<a title=\"删除\" target=\"ajaxTodo\" href=\"${webUrl}/";
  protected final String TEXT_38 = "/${data.id}?_method=DELETE\" class=\"btnDel\">删除</a>" + NL + "\t\t\t\t\t<a title=\"编辑\"  target=\"dialog\" width=\"800\" height=\"480\" href=\"${webUrl}/";
  protected final String TEXT_39 = "/${data.id}/edit\" rel=\"";
  protected final String TEXT_40 = "_edit\" class=\"btnEdit\">编辑</a>" + NL + "\t\t\t\t\t<a title=\"查看\"  target=\"dialog\" width=\"800\" height=\"480\" href=\"${webUrl}/";
  protected final String TEXT_41 = "/${data.id}\" rel=\"";
  protected final String TEXT_42 = "_show\" class=\"btnLook\">查看</a>" + NL + "\t\t\t\t</td>" + NL + "\t\t\t</tr>" + NL + "\t\t\t</c:forEach>" + NL + "\t\t</tbody>" + NL + "\t</table>" + NL + "<%-- ===================修改table显示内容===================== --%>" + NL + "\t<div class=\"panelBar\">" + NL + "\t\t<div class=\"pages\">" + NL + "\t\t\t<span>显示</span>" + NL + "\t\t\t<select class=\"combox\" name=\"numPerPage\" onchange=\"navTabPageBreak({numPerPage:this.value})\">" + NL + "\t\t\t\t<option value=\"${";
  protected final String TEXT_43 = ".numPerPage}\">${";
  protected final String TEXT_44 = ".numPerPage}</option>" + NL + "\t\t\t\t<option value=\"20\">20</option>" + NL + "\t\t\t\t<option value=\"50\">50</option>" + NL + "\t\t\t\t<option value=\"100\">100</option>" + NL + "\t\t\t\t<option value=\"200\">200</option>" + NL + "\t\t\t</select>" + NL + "\t\t\t<span>条，共${";
  protected final String TEXT_45 = ".totalCount}条</span>" + NL + "\t\t</div>" + NL + "\t\t" + NL + "\t\t<div class=\"pagination\" targetType=\"navTab\" totalCount=\"${";
  protected final String TEXT_46 = ".totalCount}\" numPerPage=\"${";
  protected final String TEXT_47 = ".numPerPage}\" pageNumShown=\"10\" currentPage=\"${";
  protected final String TEXT_48 = ".pageNum}\"></div>" + NL + "" + NL + "\t</div>" + NL + "</div>";

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    
Map<String,Object> dataMap=(Map<String,Object>) argument;
LinkedHashMap<String, String> entityAttributMap=(LinkedHashMap<String, String>)dataMap.get("entityAttributMap");
String entityClass=dataMap.get("entityClass").toString();
String entityName=dataMap.get("entityName").toString();
String EntityName=me.imvc.lib.StringTools.firstToUpperCase(entityName);
String modelClass=dataMap.get("modelClass").toString();
String modelName=dataMap.get("modelName").toString();
String ModelName=me.imvc.lib.StringTools.firstToUpperCase(modelName);
String controllerPackage=dataMap.get("controllerPackage").toString();
String controllerClass=dataMap.get("controllerClass").toString();
String viewUrl=dataMap.get("viewUrl").toString();
String view=dataMap.get("view").toString();

    stringBuffer.append(TEXT_1);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_2);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_3);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_4);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_5);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_6);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_7);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_8);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_9);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_10);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_11);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_12);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_13);
    stringBuffer.append(viewUrl);
    stringBuffer.append(TEXT_14);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_15);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_16);
    stringBuffer.append(viewUrl);
    stringBuffer.append(TEXT_17);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_18);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_19);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_20);
    stringBuffer.append(viewUrl);
    stringBuffer.append(TEXT_21);
    stringBuffer.append(viewUrl);
    stringBuffer.append(TEXT_22);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_23);
    stringBuffer.append(viewUrl);
    stringBuffer.append(TEXT_24);
    stringBuffer.append(viewUrl);
    stringBuffer.append(TEXT_25);
    stringBuffer.append(viewUrl);
    stringBuffer.append(TEXT_26);
    stringBuffer.append(viewUrl);
    stringBuffer.append(TEXT_27);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_28);
    for (String key : entityAttributMap.keySet()){
    stringBuffer.append(TEXT_29);
    stringBuffer.append(key);
    stringBuffer.append(TEXT_30);
    stringBuffer.append(entityAttributMap.get(key));
    stringBuffer.append(TEXT_31);
    }
    stringBuffer.append(TEXT_32);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_33);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_34);
    for (String key : entityAttributMap.keySet()){
    stringBuffer.append(TEXT_35);
    stringBuffer.append(key);
    stringBuffer.append(TEXT_36);
    }
    stringBuffer.append(TEXT_37);
    stringBuffer.append(viewUrl);
    stringBuffer.append(TEXT_38);
    stringBuffer.append(viewUrl);
    stringBuffer.append(TEXT_39);
    stringBuffer.append(viewUrl);
    stringBuffer.append(TEXT_40);
    stringBuffer.append(viewUrl);
    stringBuffer.append(TEXT_41);
    stringBuffer.append(viewUrl);
    stringBuffer.append(TEXT_42);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_43);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_44);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_45);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_46);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_47);
    stringBuffer.append(modelName);
    stringBuffer.append(TEXT_48);
    return stringBuffer.toString();
  }
}
